<template>
  <div class="top">
    <div class="left"></div>
    <div class="center">
      <div class="title">各省科学技术奖可视化平台</div>
    </div>
    <div class="right">
      <span class="time">{{ time }}</span>
      <span class="full" @click="fullScreen">全屏 </span>
    </div>
  </div>
</template>

<script setup lang="ts">
//@ts-ignore
import moment from 'moment'
import { ref, onMounted, onBeforeUnmount } from 'vue'

//存储当前时间
let time = ref(moment().format('YYYY年MM月DD日 hh:mm:ss'))
let timer = ref(0)
//组件挂载完毕更新当前的事件
onMounted(() => {
  timer.value = setInterval(() => {
    time.value = moment().format('YYYY年MM月DD日 hh:mm:ss')
  }, 1000)
})

onBeforeUnmount(() => {
  clearInterval(timer.value)
})
const fullScreen = () => {
  let full = document.fullscreenElement
  if (!full) {
    document.documentElement.requestFullscreen()
  } else {
    document.exitFullscreen()
  }
}
</script>

<style scoped lang="scss">
.top {
  width: 100%;
  height: 40px;
  display: flex;

  .left {
    flex: 1.5;
    background: url(../assets/top_edge.png) no-repeat;
    background-size: cover;
  }

  .center {
    flex: 2;

    .title {
      width: 100%;
      height: 74px;
      background: url(../assets/top_center.png) no-repeat;
      background-size: 100% 100%;
      text-align: center;
      line-height: 74px;
      color: #29fcff;
      font-size: 30px;
    }
  }

  .right {
    flex: 1.5;
    background: url(../assets/top_edge.png) no-repeat;
    background-size: cover;
    position: relative;
    text-align: center;
    color: #29fcff;
    font-size: 20px;
    line-height: 40px;

    .time {
      position: absolute;
      right: 50px;
    }
    .full {
      position: absolute;
      right: 0;
    }
  }
}
</style>
